package 笔试.便利蜂;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/29-18:13
 * @version:1.0
 * @function:
 */

public class Main01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] diff0 = scanner.nextLine().split(",");
        String[] income = scanner.nextLine().split(",");
        String[] worker = scanner.nextLine().split(",");
        int [] diff = Arrays.stream(diff0).mapToInt(Integer::parseInt).toArray();
        int [] incom = Arrays.stream(income).mapToInt(Integer::parseInt).toArray();
        int [] wor = Arrays.stream(worker).mapToInt(Integer::parseInt).toArray();
        int res = 0;
        for (int i : wor) {
            int index = uperk(diff,i);
            res +=incom[index];
        }
        System.out.println(res);
    }

    private static int uperk(int[] diff, int k) {
        int l = 0;
        int r = diff.length-1;
        while (l<r){
            int mid = (l+r+1)/2;
            if (diff[mid]<=k) {
                l = mid;
            }else
                r = mid -1;
        }
        if (diff[l]>k) {
            return -1;
        }
        return l;
    }

}
